//对象的解构

const obj = { name: "lagou", age: 18 };
const { name } = obj; //解构的变量名同时又是用来匹配被解构对象中的属性名
console.log(name); //'lagou'
const name = "tom";
const { name: objName } = obj; //为防止命名冲突，重新定义解构的变量名
console.log(name, objName); //"tom" "lagou"
const { name: objName = "default value" } = obj; //设置默认值

//应用场景，简化代码
const { log } = console;
log(1);
log(1);
log(1);
